Configuring Subsystem and Process MSpaces

When you configure the Subsystem to use local memory you can set the minimum size of the external MSpace for the Subsystem, networking components, and RTSS processes through the Control Panel.

You can allocate the initial memory for an individual process’ external MSpace at process startup before any code executes by using RtssRun or Task Manager to start the real-time process. This does not happen when you use RTX64 Native or Managed APIs to start a process, unless you pass the initial size of the process MSpaces to those APIs.

NOTE: Make sure the external MSpace commit size is large enough to support your application’s memory needs. If the external MSpace does not have enough memory to handle application requests, the allocation requests will fail (when Auto expand MSpaces is disabled), or a non-deterministic call will be made to acquire more memory from Windows based on the expand size set in the Control Panel.

MSpaces logic can be configured to Automatically Expand and/or Shrink. When an MSpace does not have enough memory to fulfill allocation requests, the Subsystem behaves as follows:

The table below describes the configurable MSpace behaviors:

Behavior MSpaces
 

Subsystem Default

(via Control Panel)

Individual Override

(via RtssRun and Task Manager)

Whether to allocate memory from Local or Windows

Yes

No

 

Whether or not to allocate MSpaces memory at process startup

No

Yes

NOTE: This does not happen when you use RTX64 Native or Managed APIs to start a process, unless you pass the initial size of the process MSpaces to those APIs.

Whether or not to automatically expand MSpaces on depletion

Yes

Yes

/e expand_size

Setting the minimum expandable size of the external MSpace

Yes

Yes

/e expand_size

Whether or not to automatically shrink external MSpace on freeing

Yes No

Setting the minimum size of a process MSpace

Yes

Yes

/i initial_size

NOTE: When the Subsystem is configured to use Local Memory, and you run your process using RtssRun or the RTX64 Task Manager, the RTSS process’s external MSpace is allocated at process startup before any code executes. This does not happen when you use RTX64 Native or Managed APIs to start a process, unless you pass the initial size of the process MSpaces to those APIs.

NOTE: The expandable feature of a process’ external MSpace can be individually overridden using RtssRun with the /e expand_size option. When the specified /e expand_size is zero, this disables automatic expansion for the process’ MSpaces.

NOTE: A process’ MSpaces can be configured to shrink automatically at the time of allocation, trimming its pool cache, or freeing memory allocated directly from the MSpaces. This shrinking decreases the free memory in the MSpaces. However, it does not shrink an MSpace below its minimum size. You can disable this automatic shrink feature in the Control Panel. At process exit, all MSpace memory will be freed.

Regardless of the Subsystem default setting for memory use and the setting for MSpaces, you can monitor the size of the local pool and pool cache for any MSpace using RtQueryProcessMSpace. You can expand the local pool by using RtExpandMSpace. Rather than wait until the MSpace memory is fully depleted, you can force the MSpace to expand. This allows you to decide when to handle a non-deterministic call within your application.

NOTE: You cannot expand your MSpace or request additional memory from Windows from within a shutdown handler.

If Use local memory is selected in the Control Panel, all memory allocations explicitly or implicitly in the RTSS application are allocated from the Subsystem or process MSpaces. As a result, the following functions become deterministic and can be called in the shutdown handler:

RtCreateSharedMemory

malloc

RtCreateSemaphore

RtOpenSharedMemory

calloc

RtOpenSemaphore

HeapAlloc

realloc

RtCloseHandle

HeapCreate

free

InitializeCriticalSection

HeapDestroy

RtCreateEvent

DeleteCriticalSection

HeapFree

RtOpenEvent

CreateThread* The stack has no guard page for the thread created in the local memory pool.

HeapReAlloc

RtCreateMutex

 

RtAllocateLocalMemory

RtOpenMutex

 

Related topics: